<template>
    <div>
        <el-dialog
            :visible.sync="is_show"
            title="钱包明细"
            center
        >
            <div>
                <el-card
                    v-for="(item, index) in detailData"
                    :key="index"
                >
                    <div class="order-details">
                        <div class="order-item">
                            <div>
                                <span class="title" v-if="item.type == 0">提现</span>
                                <span class="title" v-else-if="item.type == 1">推荐所得</span>
                                <span class="title" v-else-if="item.type == 2">结案所得</span>
                                <span class="title" v-else-if="item.type == 3">惩戒</span>
                                <span class="title" v-else-if="item.type == 4">奖励所得</span>
                                <div class="c999">{{item.created_at}}</div>
                            </div>
                            <span :class="['value', item.money.indexOf('-') > -1 ? 'unfinish' : 'finish']"><span v-if="item.money.indexOf('-') == -1">+</span>{{item.money}}元</span>
                        </div>
                    </div>
                </el-card>
            </div>
        </el-dialog>
    </div>
</template>

<script>
export default {
    data() {
        return {
            is_show: false,
            agent_id: null,
            detailData: []
        }
    },

    methods: {
        async showOn(id) {
            this.agent_id = id
            this.getInfo()
        },
        getInfo() {
            this.$axios.get('/api/drawing/wallet/agent_detail', {
                params: {
                    agent_id: this.agent_id,
                    perPage: 200
                }
            }).then(res => {
                if (res.data.code == 200) {
                     if (res.data.data.length == 0) {
                        this.$message({
                            type: 'error',
                            message: '暂无钱包明细'
                        })
                        return
                    }
                    this.detailData = res.data.data
                    this.is_show = true
                } else {
                    this.$message({
                        type: 'error',
                        message: res.data.message
                    })
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
/deep/.el-dialog {
    .el-card {
        margin-bottom: 20px;
        &:nth-last-child(1) {
            margin-bottom: 0;
        }
    }
    .el-card__body {
        display: flex;
        align-items: center;
        .order-details {
            flex: 1;
            .order-item {
                display: flex;
                font-weight: bold;
                align-items: center;
                .title {
                    width: 131px;
                    display: inline-block;
                    text-align: justify;
                    text-align-last: justify;
                }
                .value {
                    flex: 1;
                    text-align: right;
                }
            }
        }
    }
}
</style>
